//app.js wx6a469e0c3ae3236e
//let BASEURL = require('/utils/util.js').BASEURL
App({
  onLaunch: function() {
     console.log('刚进入onLaunch内部');
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    // 获取手机系统信息
    wx.getSystemInfo({
      success: res => {
        //导航高度
        this.globalData.navHeight = res.statusBarHeight + 46;			
      },
      fail(err) {
        console.log(err);
      }
    })

    // 自动登录方法
    wx.login({
      success: res => {
         if(res.code){
            console.log(res.code)
            wx.request({
              url: 'https://api.xingzhishujy.com/v1/register/register',
               method: 'post',
               header: {
                  'content-type': 'application/x-www-form-urlencoded' // 默认值
               },
               data: {
                  code: res.code
               },
               success: e => {
                  let vm = this
                  //登录成功 本地缓存中指定的 成功key  ACCESSTOKEN 
                  if (e.data.status == 'succeed') {
                     	//console.log(e)
                     wx.setStorageSync('ACCESSTOKEN', e.data.data.token)
                    // console.log(e.data.data.token)
                    // debugger
                     if (vm.userInfoReadyCallback) {
                        vm.userInfoReadyCallback(e.data.data.token)
                     }
                  }
               }
            }) 
         } else{
            console.log('登录失败'+res)
         }
      
      }
    })
  },

  globalData: {
    userInfo: null,
    navHeight: 0,
    backPath: '',
    ajaxIndex: false,
    type:1
   
  }
})